package com.example.demo.common;

import org.springframework.util.StringUtils;

/**
 * 字符串的截取工具类
 * 将文章正文截取成文章摘要
 */
public class StringTools {

    public static String subLength(String val, int maxLength) {
        if (!StringUtils.hasLength(val) || maxLength <= 0) return val;
        if (val.length() <= maxLength) return val;
        return val.substring(0, maxLength);
    }

}
